﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SdmxMl.Common;


namespace SdmxMl.Panels
{
    public partial class DlgListSearchResult : Form
    {
        TreeNode selectedNode;
        private List<TreeNode> aList;

        public TreeNode SelectedNode
        { get { return selectedNode; } }

        public DlgListSearchResult(List<TreeNode> list)
        {
            InitializeComponent();
            aList = list;

            foreach (TreeNode node in list)
            {
                ISearchIdName aBO = node.Tag as ISearchIdName;
                string[] arr = node.Tag.GetType().ToString().Split('.');
                string type = ": ";
                if (arr.Length > 0)
                    type = arr[arr.Length - 1] + type;
                this.listBoxResult.Items.Add(type +  node.Text);
            }

        }

        private void listBoxResult_DoubleClick(object sender, EventArgs e)
        {
            if (listBoxResult.SelectedIndex >= 0)
                selectedNode = aList[listBoxResult.SelectedIndex];
            this.DialogResult = DialogResult.OK;

        }
    }
}
